/*
 * @(#)TestCase.java
 *
 * Revision:
 * Author                                         Date           
 * --------------------------------------------   ------------   
 *  Jeremias D. Serafim de Araujo                     14/11/2012    
 */


package br.edu.ufcg.splab.generator;



import java.util.ArrayList;

import br.edu.ufcg.splab.core.InterfaceEdge;

/**
 * A class that represents a test case.
 * A test case is a list of edges.
 *
 **/

public class TestCase {

	
	/**
	 * testCase is a list of edges
	 * 
	 */
	private ArrayList<InterfaceEdge> testCase;
	
	public TestCase(){
		this.testCase = new ArrayList<InterfaceEdge>();
	}

	public TestCase(ArrayList<InterfaceEdge> path){
		this.testCase = new ArrayList<InterfaceEdge>(path);
	}
	
	
	/**
	 * 
	 * Appends the edge in this testCase
	 * @param edge is the edge to add
	 */
	public void addEdge(InterfaceEdge edge){
		this.testCase.add(edge);
	}
	
	
	/**
	 * Checks if the test case contains a specific edge
	 * 
	 * @param edge 
	 * @return  <code>true</code> if the test case contains the edge; 
	 * <code>false</code> otherwise
	 */
	public boolean contains(InterfaceEdge edge){
		return this.testCase.contains(edge);
	}
	
	/**
	 * Removes the occurrence of the specified element.
	 * 
	 * @param edge The edge to be removed from a test case
	 */
	
	public void removeEdge(InterfaceEdge edge){
		this.testCase.remove(edge);
	}
	
	/**
	 * 
	 * Return this testCase
	 * 
	 * @return testCase
	 */
	public ArrayList<InterfaceEdge> getTestCase(){
		return this.testCase;
	}
	
	
	/**
	 * Return the number of elements(edges) in this testCase
	 *
	 * @return the number of edges of this testCase
	 */
	public int size() {
		return this.testCase.size();
	}
	
	/**
	 * 
	 * Return edge in position specified
	 * @param i position of edge
	 * @return edge is the edge returned
	 */
	public  InterfaceEdge get(int i) {
		return this.testCase.get(i);
	}
	
	/**
	 * Remove all edges of a testCase
	 */
	public void clear(){
		this.testCase.clear();
	}
	
	
	
	/**
	 * Return a string with label(type)
	 * ex: b(CONDITIONS)-a(DEFAULT)
	 * 
	 */
	@Override
	public String toString() {
		String s="";
		for(InterfaceEdge edge:this.testCase){
			//s+=edge.toString();
			s+= edge.getLabel() +"("+edge.getType()+")"+"-";
		}
		return s+"";
	}
	
	public ArrayList<InterfaceEdge> toArray() {
		return testCase;
	}
	
	public TestCase clone(){
		TestCase tc = new TestCase();
		for(InterfaceEdge e: this.getTestCase()){
			tc.addEdge(e);
		}
		return tc;
	}
	
//	public static void main(String[] args) {
//		TestCase t = new TestCase();
//		
//		InterfaceVertex v1 = new Vertex("0");
//
//		InterfaceVertex v2 = new Vertex("1");
//
//		InterfaceVertex v3 = new Vertex("2");
//		InterfaceEdge e2 = new Edge(v1, "a", v2,Type.DEFAULT);
//		InterfaceEdge e1 = new Edge(v1, "b", v3,Type.DEFAULT);
//		t.addEdge(e1);
//		t.addEdge(e2);
//		System.out.println(e1.getTipo());
//		e1.setTipo(Type.CONDITIONS);
//		System.out.println(e1.getTipo());
//		System.out.println(t.toString());
//	}





	
}
